//
//  CLMainViewController.swift
//  weibo001
//
//  Created by CL on 16/7/9.
//  Copyright © 2016年 CL. All rights reserved.
//

import UIKit

class CLMainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

       let clTabBar = CLTabBar()
       
        setValue(clTabBar, forKey: "tabBar")
        
        addChildViewController(CLHomeTableViewController(), title: "首页", imageNamed: "tabbar_home")
        addChildViewController(CLMessageTableViewController(), title: "消息", imageNamed: "tabbar_message_center")
        
         addChildViewController(CLDiscoverTableViewController(), title: "发现", imageNamed: "tabbar_discover")
          addChildViewController(CLProfileTableViewController(), title: "我的", imageNamed: "tabbar_profile")
        
    }

    func addChildViewController(childController: UIViewController, title: String, imageNamed: String) {
        //设置标题
        childController.title = title
        //设置图片
        childController.tabBarItem.image = UIImage(named:imageNamed)
        childController.tabBarItem.selectedImage = UIImage(named:imageNamed + "_selected")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        
        //设置字体颜色
        childController.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.orangeColor()], forState: .Selected)
        
        //创建导航控制器
        
        let nav = UINavigationController(rootViewController: childController)
        
        addChildViewController(nav)
        
    }

 

}
